<?php

namespace Modules\Car\Jobs;

use Illuminate\Bus\Queueable;
use Illuminate\Queue\SerializesModels;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Modules\Car\Entities\Insurance;
use Modules\Car\Entities\RecognizeDrivingLicense;

//车辆保险操作
class InsuranceOverTimeJob implements ShouldQueue
{
    use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;

    /**
     * Create a new job instance.
     *
     * @return void
     */
    public function __construct()
    {
        //
    }

    /**
     * Execute the job.
     *
     * @return void
     */
    public function handle()
    {
        $list = Insurance::query()
            ->where('vci_start','>',now())
            ->whereNull('end')
            ->pluck('vci_end')
            ->toArray();
        if(count($list)>0){
            RecognizeDrivingLicense::query()
                ->whereIn('id',$list)
                ->update(['use_status'=>1]);
        }
    }
}
